#if !defined(_RSS_ITEM_H_)
#define _RSS_ITEM_H_

#include <string>
#include <map>
#include <iostream>

#include "tinystr.h"
#include "tinyxml.h"

using std::cout;
using std::endl;
using std::map;
using std::string;

class Item
{
	map<string,string> elements_;
public:
	Item()
	{
		elements_["guid"]="";
	}
	string getID()
	{		
		return elements_["guid"];
	}
	string getURL()
	{
		return elements_["url"];
	}
	void AddElem(const string&key, const string& value )
	{
		elements_[key]=value;
	}
	void ParseData(const map<string,string>& raw_input)
	{
		elements_=raw_input;
		if(elements_["guid"].empty()||elements_["guid"].size()==0)
		{
			ResetID();
		}
	}

	void printElems()
	{
		map<string,string>::iterator it_elem=elements_.begin();
		while(it_elem!=elements_.end())
		{
			cout<<it_elem->first<<"\t"<<it_elem->second<<endl;
			it_elem++;
		}
		cout<<string(30,'*')<<endl;
	}


   /*
	* Reset ID to the value of link, as link is always unique.
	*/
	void ResetID()
	{
		elements_["guid"]=elements_["url"];
	}

};

#endif
